package com.binest.foreignInvest.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.foreignInvest.domain.ForeignInvest;
import com.binest.foreignInvest.service.IForeignInvestService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 对外投资Controller
 * 
 * @author wwd
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/foreignInvest")
public class ForeignInvestController extends BaseController
{
    @Autowired
    private IForeignInvestService foreignInvestService;

    /**
     * 查询对外投资列表
     */
    @PreAuthorize("@ss.hasPermi('foreignInvest:foreignInvest:list')")
    @GetMapping("/list")
    public TableDataInfo list(ForeignInvest foreignInvest)
    {
        startPage();
        List<ForeignInvest> list = foreignInvestService.selectForeignInvestList(foreignInvest);
        return getDataTable(list);
    }

    /**
     * 导出对外投资列表
     */
    @PreAuthorize("@ss.hasPermi('foreignInvest:foreignInvest:export')")
    @Log(title = "对外投资", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ForeignInvest foreignInvest)
    {
        List<ForeignInvest> list = foreignInvestService.selectForeignInvestList(foreignInvest);
        ExcelUtil<ForeignInvest> util = new ExcelUtil<ForeignInvest>(ForeignInvest.class);
        util.exportExcel(response, list, "对外投资数据");
    }

    /**
     * 获取对外投资详细信息
     */
    @PreAuthorize("@ss.hasPermi('foreignInvest:foreignInvest:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(foreignInvestService.selectForeignInvestById(id));
    }

    /**
     * 新增对外投资
     */
    @PreAuthorize("@ss.hasPermi('foreignInvest:foreignInvest:add')")
    @Log(title = "对外投资", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ForeignInvest foreignInvest)
    {
        return toAjax(foreignInvestService.insertForeignInvest(foreignInvest));
    }

    /**
     * 修改对外投资
     */
    @PreAuthorize("@ss.hasPermi('foreignInvest:foreignInvest:edit')")
    @Log(title = "对外投资", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ForeignInvest foreignInvest)
    {
        return toAjax(foreignInvestService.updateForeignInvest(foreignInvest));
    }

    /**
     * 删除对外投资
     */
    @PreAuthorize("@ss.hasPermi('foreignInvest:foreignInvest:remove')")
    @Log(title = "对外投资", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(foreignInvestService.deleteForeignInvestByIds(ids));
    }
}
